package com.zhou.test.controller;

import com.zhou.test.pojo.User;
import com.zhou.test.service.UserService;
import com.zhou.test.utils.RedisUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class LoginController {
    @Resource
    private UserService userService;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String Login(Model model) {
        model.addAttribute("user", userService.FindByUsername("zhou"));
        RedisUtils.setString("a", "b");
        String aa = RedisUtils.getString("a");
        return "Login";
    }

    @RequestMapping(value = "/GetUser", method = RequestMethod.GET)
    @ResponseBody //用于返回字符串,不写即返回视图
    public User GetUser(String name) {
        User user = userService.FindByUsername(name);
        return user;
    }
}
